<?php
/**
 * // +----------------------------------------------------------------------
 * //            -------------------------
 * //           /   / ------------------\  \
 * //                                          \  \
 * //                                           /  /
 * //          /  /  ------------------- /  /
 * //        /  /  ----------------------
 * //      /  /
 * //      \  \
 * //        \  \  ------------------ /  /
 * //          \  \--------------------/
 * // +----------------------------------------------------------------------
 * // | Copyright (c) 2016 Sage  All rights reserved.
 * // +----------------------------------------------------------------------
 * // | Author: Sage
 * // +----------------------------------------------------------------------
 *
 */

/**
 * Created by PhpStorm.
 * User: Sage
 * Date: 2017/12/7
 * Time: 15:35
 */
namespace KysbsUtils\Service;

/**
 * RPC服务
 * Class RpcService
 * @package KysbsUtils\Service
 */
class RpcService {
    const RPC_URL =RUN_ENV=='PRODUCE'?'http://systask.kysbs.com':
        (RUN_ENV=='TEST'?'http://testsystask.kysbs.com':'http://testsystask.kysbs.com');

    function client(){
        try{
            $client = \Hprose\Http\Client::create(self::RPC_URL.'/rpc/exec', false);
        } catch(\Exception $e){
            echo $e->getMessage();
            exit();
        }
        return $client;
    }

    function __call($name , $arguments) {
        // TODO: Implement __call() method.
        if(!method_exists($this,$name)){
            $client=$this->client();
            return $client->$name(...$arguments);
        }
    }
}